#!/bin/bash

SERVICE_NAME="MarketService"
INSTALL_DIR="/usr/local"
CONFIG_DIR="/etc/${SERVICE_NAME}"
LOG_DIR="/var/log/${SERVICE_NAME}"

# 检查配置文件
if [ ! -d "$CONFIG_DIR" ]; then
    echo "Error: Configuration directory not found: $CONFIG_DIR"
    exit 1
fi

# 检查日志目录
if [ ! -d "$LOG_DIR" ]; then
    mkdir -p "$LOG_DIR"
    chmod 777 "$LOG_DIR"
fi

# 启动服务
$INSTALL_DIR/bin/$SERVICE_NAME "$CONFIG_DIR/market.json" > "$LOG_DIR/market.log" 2>&1 &

echo "Market service started. Check logs at $LOG_DIR/market.log"